//- Copyright (c) 2016 Lucky Byte, Inc.
extends layout

append scripts
  script(src="/js/table.js")

append content
  form.ui.form.segment.attached#search_form(
    method="post" action="#{search_form_action}")

    input(type="hidden" name="page_no" value="#{page_no}")
    input(type="hidden" name="page_rows" value="#{page_rows}")

    .fields
      .field.three.wide#keyword
        .ui.search
          .ui.icon.input.small.compact
            input.prompt(type="text" name="keyword" value="#{keyword}"
              placeholder="输入关键字回车查询")
            i.search.link.icon

      block form_items

  block gap

  table.ui.sortable.celled.structured.attached.table.small.compact#table
    thead
      block thead

    tbody
      block tbody

    tfoot.full-width
      tr  
        th(colspan="100")
          .ui.right.floated.pagination.menu
            if page_no > 1
              a.icon.item(data-page-no="1"
                style="padding-top:0px; padding-bottom:0px;")
                i.left.angle.double.icon.large
              a.icon.item(data-page-no="#{page_no - 1}"
                style="padding-top:0px; padding-bottom:0px;")
                i.left.angle.icon.large

            .item 每页行数
            .item
              .ui.compact.dropdown#page_rows
                .text 10
                i.dropdown.icon
                .menu
                  .item(data-value="10") 10
                  .item(data-value="15") 15
                  .item(data-value="20") 20
                  .item(data-value="30") 30
                  .item(data-value="50") 50
                  .item(data-value="100") 100

            - var page_num = total > 0 ? Math.floor((total - 1) / page_rows + 1) : 1

            .item 共 #{total} 条记录
            .item 页
            input(type="text" size="1" style="text-align:center;" value="#{page_no}")
            .item#page_num(data-page-num="#{page_num}") / #{page_num}

            if page_no < page_num
              a.icon.item(data-page-no="#{page_no + 1}"
                style="padding-top:0px; padding-bottom:0px;")
                i.right.angle.icon.large
              a.icon.item(data-page-no="#{page_num}"
                style="padding-top:0px; padding-bottom:0px;")
                i.right.angle.double.icon.large
